/*
Copyright 2010,2011 Matt Van Der Westhuizen

This file is part of CGLL.

CGLL is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

CGLL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with CGLL.  If not, see <http://www.gnu.org/licenses/>.
*/

package org.chaoticengine.cgll.entity.component.tween;

import org.newdawn.slick.GameContainer;

/**
 *
 * @author Matt Van Der Westhuizen <mattpwest@gmail.com>
 */
public abstract class Tween {
    public static enum RepeatMode {None, Loop, PingPong};

    protected int timePassed = 0;
    protected int duration = 0;
    protected RepeatMode repeat = RepeatMode.None;
    protected TweenComponent owner = null;

    public Tween(int duration) {
        this.duration = duration;
    }

    public int getDuration() {
        return duration;
    }

    public void setDuration(int duration) {
        this.duration = duration;
    }

    public TweenComponent getOwner() {
        return owner;
    }

    public void setOwner(TweenComponent owner) {
        this.owner = owner;
    }

    public int getTimePassed() {
        return timePassed;
    }

    public void setTimePassed(int timePassed) {
        this.timePassed = timePassed;
    }

    public RepeatMode getRepeatMode() {
        return repeat;
    }

    public void setRepeatMode(RepeatMode repeat) {
        this.repeat = repeat;
    }

    public void update(GameContainer gc, int delta) {
        timePassed += delta;
        doUpdate(delta);
    }

    public boolean isDone() {
        if (repeat.equals(RepeatMode.None)) {
            return(timePassed >= duration);
        } else {
            return(false);
        }
    }

    public abstract void doUpdate(int delta);
}
